package com.hongyi.modelcontest.modular.contest.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hongyi.modelcontest.core.common.page.LayuiPageFactory;
import com.hongyi.modelcontest.modular.contest.entity.ContestInfo;
import com.hongyi.modelcontest.modular.contest.mapper.ContestInfoMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

@Service
public class ContestInfoService extends ServiceImpl<ContestInfoMapper, ContestInfo> {
    @Resource
    private ContestInfoMapper contestInfoMapper;

    public IPage list(String name) {
        Page page = LayuiPageFactory.defaultPage();
        QueryWrapper<ContestInfo> query = new QueryWrapper<>();
        if (!StringUtils.isEmpty(name)) {
            query.lambda().like(ContestInfo::getContestName, name);
        }
        return contestInfoMapper.selectPage(page, query);
    }


}
